using UnityEngine;
using System.Collections;

public class ScrollPlane : MonoBehaviour {

	public bool scroolMode = false;
	public Vector2 lastMousePosition;
	public float magnitudeDeRolagem = 1;
	public static float yMax, yMin;
	
	void Awake () {
	
		#if UNITY_STANDALONE_WIN || UNITY_WEBPLAYER
		this.enabled = false;
		#endif
	}
	
	void Update () {
		
		if(scroolMode)
		{
			float diferencaY =  lastMousePosition.y - Input.mousePosition.y ;
			lastMousePosition = Input.mousePosition;
			Debug.Log(diferencaY + "	 diferenca Y");
			
			Camera.mainCamera.transform.position = new Vector3( Camera.mainCamera.transform.position.x, Camera.mainCamera.transform.position.y + magnitudeDeRolagem /100* diferencaY, Camera.mainCamera.transform.position.z);
			
			if(Camera.mainCamera.transform.position.y > yMax)
			{
				Camera.mainCamera.transform.position = new Vector3( Camera.mainCamera.transform.position.x, yMax, Camera.mainCamera.transform.position.z);
			}
			
			if(Camera.mainCamera.transform.position.y < yMin)
			{
				Camera.mainCamera.transform.position = new Vector3( Camera.mainCamera.transform.position.x, yMin, Camera.mainCamera.transform.position.z);
			}
			
				
		}
	
	}
	void OnMouseDown()
	{
		scroolMode = true;
		this.lastMousePosition = Input.mousePosition;
		Debug.Log("Plano");
	}
	
	void OnMouseUp()
	{
		scroolMode = false;
 	}
}
